from django.db import models
from django.db.models.fields import CharField, EmailField
from django.contrib.auth.models import User

class Admin(models.Model):
    username = CharField(max_length=30)
    password = CharField(max_length=30)
    email = EmailField()      
    
# Create your models here.
class Professor(models.Model):
    username = CharField(max_length=30)
    nome = models.CharField(max_length=200)
    cpf = models.CharField(max_length=11)
    telefone = models.CharField(max_length=20)
    email = models.EmailField()
    
    def __unicode__(self):
        return self.nome

class Endereco(models.Model):
    professor = models.ForeignKey(Professor)
    rua = models.CharField(max_length=200)
    numero = models.IntegerField()
    bairro = models.CharField(max_length=100)
    cidade = models.CharField(max_length=100)
    estado = models.CharField(max_length=2)
    cep = models.CharField(max_length=9)

class Aluno(models.Model):
    username = models.CharField(max_length=30)
    nome = models.CharField(max_length=200)
    matricula = models.IntegerField()
    email = models.EmailField()
    
    def __unicode__(self):
        return self.nome
    
class EnderecoAluno(models.Model):
    professor = models.ForeignKey(Aluno)
    rua = models.CharField(max_length=200)
    numero = models.IntegerField()
    bairro = models.CharField(max_length=100)
    cidade = models.CharField(max_length=100)
    estado = models.CharField(max_length=2)
    cep = models.CharField(max_length=9)
    
class Disciplina(models.Model):    
    professor = models.ForeignKey(Professor)
    nome = models.CharField(max_length=100)
    conteudo = models.CharField(max_length=300)
    cargaHoraria = models.IntegerField()
    
    def __unicode__(self):
        return self.nome
    
    
class AlunoCursaDisciplina(models.Model):
    disciplina = models.ForeignKey(Disciplina)
    aluno = models.ForeignKey(Aluno)
    nota = models.IntegerField()
    faltas = models.IntegerField()
    
    def _unicode_(self):
        return self.aluno + ' cursa ' + self.disciplina
    
